#define DEBUG
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

const int maxn=3000;
const long long inf=0x7ffffffffffffff;

int main() {
  freopen("rhombus.in", "r", stdin);
  freopen("rhombus.ans", "w", stdout);

  static int a[maxn+1][maxn+1];
  int n, m, h, ty;
  scanf("%d %d %d %d", &n, &m, &h, &ty);
  for (int i=1; i<=n; i++) {
    for (int j=1; j<=m; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  long long ans=-inf;
  int ax=0, ay=0;
  for (int i=h; i+h-1<=n; i++) {
    for (int j=h; j+h-1<=m; j++) {
      long long f=0;
      for (int x=i-h+1; x<=i+h-1; x++) {
	for (int y=j-h+1; y<=j+h-1; y++) {
	  if (abs(x-i)+abs(y-j)<h) {
	    f+=a[x][y];
	  }
	}
      }
      if (f>ans) {
	ans = f;
	ax=i, ay=j;
      }
    }
  }

  printf("%lld", ans);
  // printf("%lld\n%d %d", ans, ax, ay);

  return 0;
}
